package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.model.dto.MerchantReportDTO;
import com.zfzs.post.model.dto.MineMerchantDTO;
import com.zfzs.post.model.dto.QueryMerchantPageListDTO;
import com.zfzs.post.service.MerchantApiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author wq
 *
 * @date 2019/9/26 10:49
 * @description
 */
@RestController
@Slf4j
@RequestMapping("merchant/")
public class MerchantApiController {

    @Autowired
    private MerchantApiService merchantApiService;

    /**
     * 报备商户
     *
     * @param dto
     * @return
     */
    @Log("报备商户")
    @PostMapping("report_merchant")
    public ResponseResult reportMerchant(@Validated @RequestBody MerchantReportDTO dto) {
        merchantApiService.reportMerchant(dto);
        return ResponseResult.okMsg("报备商户成功");
    }

    /**
     * 我的商户
     */
    @Log("我的商户")
    @PostMapping("mine_merchant")
    public ResponseResult mineMerchant(@Validated @RequestBody MineMerchantDTO dto) {
        Map<String, Object> map = merchantApiService.mineMerchant(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 商户列表
     */
    @Log("商户列表")
    @PostMapping("merchant_list")
    public ResponseResult MerchantList(@Validated @RequestBody QueryMerchantPageListDTO dto) {
        Map<String, Object> map = merchantApiService.queryMerchantPageList(dto);
        return ResponseResult.ok(map);
    }

}
